import React, { Component } from 'react'
import { BrowserRouter as Router, Route, Redirect } from 'react-router-dom';
import CacheRoute, { CacheSwitch } from 'react-router-cache-route'
import Home from './views/home';
import News from './views/news';
import CityList from './views/cityList';
import AddCity from './views/addCity';
import Error_404 from './components/404';

class Routers extends Component<any, any> {
    render() {
        return (
            <div>
                <Router>
                    <CacheSwitch >
                        <CacheRoute when="always" multiple={5} exact={true} path="/home/:cityCode?" component={Home} />
                        <CacheRoute when="always" exact={true} path="/news" component={News} />
                        <CacheRoute when="always" exact={true} path="/cityList" component={CityList} />
                        <CacheRoute when="always" exact={true} path="/addCity" component={AddCity} />
                        <Redirect from="/" to="/home" />
                        <Route component={Error_404} />
                    </CacheSwitch>
                </Router>
            </div>
        )
    }
}
export { Routers }
